<?php

/**
 * this class provides generation of an icon button in a grid cell
 * @author		ungerboeck simon <su@militaerversand.at>
 *
 */
class GridIconButton {
    private $action = null;
    private $icon = null;
    private $path = null;
    private $title = null;


    /************************************************************************
     ************************** PUBLIC FUNCTIONS ****************************
     ************************************************************************/

    /**
     * sets the icon and the default path
     * @param         string         $icon
     */
    public function __construct($icon, $title = null) {
        $this->icon = $icon;
        $this->path = ADMIN_IMAGES;
        $this->title = $title;
    }


    /**
     * creates the icon with wraped a-tag
     * @return         string        $output
     */
    public function create() {
         $output = '<img src="' . $this->path . $this->icon . '" alt="' . $this->icon . '" ';
        $output .= (isset($this->action) ? 'style="cursor:pointer"' : '');
        $output .= (isset($this->title) ? 'title="' . $this->title . '"' : '');
        $output .= (isset($this->action) ? 'onclick="' . $this->action . '"' : '') . ' />';
        return $output;
    }


    /**
     * generates the string output for current button
     * @return         string
     */
    public function __toString() {
        return $this->create();
    }


    /************************************************************************
     **************************** GETTER / SETTER ***************************
     ************************************************************************/

    public function setAction($action) {
        $this->action = $action;
    }


    public function setIcon($icon) {
        $this->icon = $icon;
    }


    public function setPath($path) {
        $this->path = $path;
    }


    public function setTitle($title) {
        $this->title = $title;
    }


    public function getAction() {
        return $this->action;
    }


    public function getIcon() {
        return $this->icon;
    }


    public function getPath() {
        return $this->path;
    }


    public function getTitle() {
        return $this->title;
    }

    /************************************************************************
     ************************** PRIVATE FUNCTIONS ***************************
     ************************************************************************/
}